import config from "./config";
import api from './api';
import http from "./utils/request";
import tool from "./utils/tool";
import errorHandler from './utils/errorHandler';
import * as elIcons from '@element-plus/icons-vue';
import * as scIcons from './assets/icons';

import scTable from './components/scTable/index.vue';
import scTableColumn from './components/scTable/column.js';
import scUpload from './components/scUpload/index.vue';
import scUploadMultiple from './components/scUpload/multiple.vue';
import scUploadFile from './components/scUpload/file.vue';
import scFormTable from './components/scFormTable/index.vue';
import scIconSelect from '@/components/scIconSelect/index.vue';

import auth from './directives/auth';
import time from './directives/time';

export default {
    install(app) {
		//挂载全局对象
        app.provide('$CONFIG', config);
        app.provide('$API', api);
        app.provide('$HTTP', http);
        app.provide('$TOOL', tool);

		//注册全局组件
		app.component('scTable', scTable);
		app.component('scTableColumn', scTableColumn);
        app.component('scUpload', scUpload);
		app.component('scUploadMultiple', scUploadMultiple);
		app.component('scUploadFile', scUploadFile);
		app.component('scFormTable', scFormTable);
		app.component('scIconSelect', scIconSelect);

		//注册全局指令
		app.directive('auth', auth)
		app.directive('time', time)

        //统一注册el-icon图标
        for (let icon in elIcons) {
            app.component(`ElIcon${icon}`, elIcons[icon])
        }
        //统一注册sc-icon图标
        for (let icon in scIcons) {
            app.component(`ScIcon${icon}`, scIcons[icon])
        }

		//关闭async-validator全局控制台警告
		window.ASYNC_VALIDATOR_NO_WARNING = 1
		//全局代码错误捕捉
		app.config.errorHandler = errorHandler
    }
}